home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SoundEditorUtils.h
-
- Contains: SoundEditor utility functions & classes
-
- Written by: Steve Smith and Troy Gaul
-
- Copyright: © 1994,95 by Apple Computer, Inc., all rights reserved.
- */
-
-
- #ifndef _SOUNDEDITORUTILS_
- #define _SOUNDEDITORUTILS_
-
- // -- Compiler/Preprocessor Switches --
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _EXCEPT_
- // Exceptions define several important macros (ie. CHECKENV)
- // which are used in the SOM method dispatch glue. If Except.h
- // is not included early enough, exceptions may not be thrown
- // correctly when returning from a SOM method with "ev" parameter set.
- #include <Except.h>
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh> // So ODAcquireObject can be called on an ODFrame
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _ITEXT_
- #include <IText.h> // ODScriptCode, ODLangCode
- #endif
-
- #ifndef _ODDEBUG_
- #include <ODDebug.h> // ASSERT macro for inlines
- #endif
-
- #ifndef _ODUTILS_
- #include <ODUtils.h> // ODAcquireObject, etc. utilities for inlines
- #endif
-
- // -- Macintosh Includes --
-
- #ifndef __DIALOGS__
- #include <Dialogs.h> // For DialogPtr
- #endif
-
- //------------------------------------------------------------------------------
- // Forward declarations
- //------------------------------------------------------------------------------
-
- struct Environment;
- class ODDraft;
- class ODFrame;
- class ODFacet;
- class ODStorageUnit;
- class ODStorageUnitView;
- class ODWindow;
-
- //------------------------------------------------------------------------------
- // Typedefs
- //------------------------------------------------------------------------------
-
- // Define the FINF type. FINF is a font information resource that is used
- // to specify a font, style, and size as an entry in an array of the same
- // that is to exist in a 'FINF' resource in the editor.
- struct FINF {
- short font;
- short face;
- short size;
- };
-
- typedef struct FINF *FINFPtr;
-
- //------------------------------------------------------------------------------
- // Function Prototypes
- //------------------------------------------------------------------------------
-
- ODIText* GetPartName(Environment* ev, ODPart* part, ODType category);
- ODBoolean NamesAreEquivalent(Environment* ev, ODIText* fileName,
- ODIText* partName);
- void GetEditorScriptLanguage(Environment* ev, ODScriptCode* script,
- ODLangCode* language);
- void FixedToIntRect(ODRect& fixedRect, Rect& intRect);
- void IntToFixedRect(Rect& intRect, ODRect& fixedRect);
- void LoadThumbnail(Environment* ev, Handle* thumbnail);
- Rect TilePartWindow(Environment* ev, Rect* facetBounds,
- Rect* partWindowBounds);
- ODUShort CountFacets(Environment* ev, ODFrame* frame);
- FINF GetIndFINF(short id, short num);
- void SetDialogDefaults(DialogPtr dialog, ODUShort finfID = 0,
- ODUShort index = 0);
-
- void DrawTime(Environment* ev, ODFacet* facet,
- Rect& bounds, ODSShort size,
- ODSShort time);
-
- ODHandle Read1IndResource(ResType type, short index);
- void DrawEditorPicture(short index, Rect& bounds);
-
- //------------------------------------------------------------------------------
- // TempFocus
- //------------------------------------------------------------------------------
-
- class TempFocus : Destructo {
-
- public:
- TempFocus(Environment*, ODTypeToken focusType, ODFrame*);
- ~TempFocus();
-
- ODBoolean Request();
-
- private: // disallow these:
- TempFocus(const TempFocus&);
- void operator=(const TempFocus&);
-
- private:
- Environment* fEv;
- ODTypeToken fFocusType;
- ODFrame* fFrameToFocus;
- ODBoolean fAcquired;
- };
-
- //------------------------------------------------------------------------------
- // TempClipboardFocus
- //------------------------------------------------------------------------------
-
- class TempClipboardFocus : public TempFocus {
-
- public:
- TempClipboardFocus(Environment*, ODFrame*);
- };
-
- //------------------------------------------------------------------------------
- // TempHandleLockAndRememberState
- //------------------------------------------------------------------------------
-
- class TempHandleLockAndRememberState : Destructo {
-
- protected:
- ODHandle fHandle;
- ODSByte fSavedState;
-
- public:
- ~TempHandleLockAndRememberState(); // restores the handle's state
- TempHandleLockAndRememberState( ODHandle ); // locks the handle
- operator ODHandle ()
- { return fHandle; }
-
- private: // disallow these:
- TempHandleLockAndRememberState( );
- TempHandleLockAndRememberState(const TempHandleLockAndRememberState& );
- void operator=(const TempHandleLockAndRememberState& );
- };
-
- //------------------------------------------------------------------------------
- // CFrameProxy (aka CFuton)
- //------------------------------------------------------------------------------
-
- class CFrameProxy {
-
- public:
- CFrameProxy();
- ~CFrameProxy();
-
- void InitFrameProxy(ODID frameID, ODDraft* draft);
- void InitFrameProxy(Environment* ev, ODFrame* frame);
- void Purge(Environment* ev);
-
- ODFrame* GetFrame(Environment* ev);
- void SetFrame(Environment* ev, ODFrame* frame);
- ODBoolean FrameIsLoaded(Environment* ev);
- ODID GetID();
- ODDraft* GetDraft();
-
- private:
- ODFrame* fFrame;
- ODID fID;
- ODDraft* fDraft;
- };
-
- //------------------------------------------------------------------------------
- // CFrameInfo
- //------------------------------------------------------------------------------
-
- class CFrameInfo {
-
- public:
- CFrameInfo(ODSession* session);
- ~CFrameInfo();
-
- void Externalize(Environment* ev, ODStorageUnitView* storageUnitView);
- void CleanseFrameInfoProperty(Environment* ev, ODStorageUnit* storageUnit);
- void ExternalizeFrameInfo(Environment* ev, ODStorageUnit* storageUnit,
- ODDraftKey key, ODFrame* scopeFrame);
- void CloneInto(Environment *ev, ODDraftKey key,
- ODStorageUnitView* storageUnitView,
- ODFrame* scopeFrame);
- void InitFromStorage(Environment* ev, ODStorageUnitView* storageUnitView);
-
- ODBoolean IsFrameActive();
- void SetFrameActive(ODBoolean active);
- ODBoolean FrameNeedsReactivating();
- void SetFrameReactivate(ODBoolean reactivate);
- ODFacet* GetActiveFacet();
- void SetActiveFacet(ODFacet* facet);
- void SetSourceFrame(Environment* ev, ODFrame* frame);
- ODFrame* GetSourceFrame(Environment* ev);
- void ReleaseSourceFrame(Environment* ev);
- ODBoolean HasSourceFrame();
- ODWindow* AcquirePartWindow(Environment* ev);
- void SetPartWindow(Environment* ev, ODWindow* window);
- void SetDependentFrame(Environment* ev, ODFrame* frame);
- ODFrame* GetDependentFrame(Environment* ev);
- ODBoolean HasDependentFrame();
- void ReleaseDependentFrame(Environment* ev);
- void SetShouldDisposeWindow(ODBoolean should);
- ODBoolean ShouldDisposeWindow();
-
- private:
- CFrameInfo(); /* don't want parts to call */
-
- ODSession* fSession;
- ODBoolean fFrameActive;
- ODBoolean fFrameReactivate;
- ODBoolean fShouldDisposeWindow;
- ODFacet* fActiveFacet;
- CFrameProxy* fSourceFrame;
- CFrameProxy* fDependentFrame;
- ODID fPartWindowID;
- };
-
-
- //-------------------------------------------------------------------------
- // Inline methods
- //-------------------------------------------------------------------------
-
- //=========================================================================
- // CFrameProxy
- //=========================================================================
-
- inline CFrameProxy::CFrameProxy()
- {
- fFrame = kODNULL;
- fID = kODNULLID;
- fDraft = kODNULL;
- }
-
- inline CFrameProxy::~CFrameProxy()
- {
- ODSafeReleaseObject(fFrame);
- }
-
- inline void CFrameProxy::InitFrameProxy(ODID frameID, ODDraft* draft)
- {
- ASSERT(draft!=kODNULL, kODErrIllegalNullInput);
-
- fFrame = kODNULL;
- fID = frameID;
- fDraft = draft;
- }
-
- inline void CFrameProxy::InitFrameProxy(Environment* ev, ODFrame* frame)
- {
- ASSERT(frame!=kODNULL, kODErrIllegalNullFrameInput);
-
- this->SetFrame(ev,frame);
- }
-
- inline ODID CFrameProxy::GetID()
- {
- return fID;
- }
-
- inline ODDraft* CFrameProxy::GetDraft()
- {
- return fDraft;
- }
-
-
- //=========================================================================
- // CFrameInfo
- //=========================================================================
-
- inline ODBoolean CFrameInfo::IsFrameActive()
- {
- return fFrameActive;
- }
-
- inline void CFrameInfo::SetFrameActive(ODBoolean active)
- {
- fFrameActive = active;
- }
-
- inline ODBoolean CFrameInfo::FrameNeedsReactivating()
- {
- return fFrameReactivate;
- }
-
- inline void CFrameInfo::SetFrameReactivate(ODBoolean reactivate)
- {
- fFrameReactivate = reactivate;
- }
-
- inline ODFacet* CFrameInfo::GetActiveFacet()
- {
- return fActiveFacet;
- }
-
- inline void CFrameInfo::SetActiveFacet(ODFacet* facet)
- {
- fActiveFacet = facet;
- }
-
- inline ODFrame* CFrameInfo::GetSourceFrame(Environment* ev)
- {
- return fSourceFrame->GetFrame(ev);
- }
-
- inline ODBoolean CFrameInfo::HasSourceFrame()
- {
- return (fSourceFrame != kODNULL);
- }
-
- inline ODFrame* CFrameInfo::GetDependentFrame(Environment* ev)
- {
- return fDependentFrame->GetFrame(ev);
- }
-
- inline ODBoolean CFrameInfo::HasDependentFrame()
- {
- return (fDependentFrame != kODNULL);
- }
-
- inline void CFrameInfo::SetShouldDisposeWindow(ODBoolean should)
- {
- fShouldDisposeWindow = should;
- }
-
- inline ODBoolean CFrameInfo::ShouldDisposeWindow()
- {
- return fShouldDisposeWindow;
- }
-
- #endif
-
-
-